package Homework6;

public class StudentWithException {
    private int age;
    private static int objectCount = 0;

    public StudentWithException(int age) throws InvalidAgeException {
        setAge(age);
        objectCount++;
    }

    public void setAge(int age) throws InvalidAgeException {
        if (age <= 0) {
            throw new InvalidAgeException(age);
        }
        this.age = age;
    }

    public static int getObjectCount() {
        return objectCount;
    }
}
